package com.tracy.lifeproject.discovery.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by asus on 2016/7/20.
 */
public class DiscoveryViewPagerAdapter extends FragmentPagerAdapter {

    private String[] mTitle=new String[]{"攻略","商品"};

    private List<Fragment> mFragmentList;

    public DiscoveryViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList == null ? 0 : mFragmentList.size();
    }

    public void setDatas(List<Fragment> fragmentList) {
        this.mFragmentList = fragmentList;
        notifyDataSetChanged();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitle[position];
    }
}
